package com.example.teamtribe.main.club.clubintroduce;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.teamtribe.main.club.clubintroduce.media.AlbumFragment;
import com.example.teamtribe.main.club.clubintroduce.media.VideoFragment;

/**
 * Created by lenovo on 2018/5/4.
 */

public class ClubIntroducePagerAdapter extends FragmentPagerAdapter {

    private VideoFragment fragVideo;
    private IntroduceFragment fragIntroduce;
    private AlbumFragment fragAlbum;
    private String[] titles = new String[] {"社团简介", "社团相册", "社团视频"};

    public ClubIntroducePagerAdapter(FragmentManager fm) {
        super(fm);
        fragIntroduce = new IntroduceFragment();
        fragAlbum= new AlbumFragment();
        fragVideo = new VideoFragment();
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return fragIntroduce;
            case 1:
                return fragAlbum;
            case 2:
                return fragVideo;
            default:
                return fragIntroduce;
        }
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public int getItemPosition(Object object) {
        if (object instanceof IntroduceFragment) {
            return 0;
        } else if (object instanceof AlbumFragment) {
            return 1;
        } else {
            return 2;
        }
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}

